﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Foggy.DataTemplateSelectors
{
    using System.Windows;
    using System.Windows.Controls;

    using Foggy.Users;

    public class UserDataTemplateSelector : DataTemplateSelector
    {
        /// <summary>
        /// Gets or sets the user template.
        /// </summary>
        /// <value>The user template.</value>
        public DataTemplate UserTemplate { get; set; }

        /// <summary>
        /// When overridden in a derived class, returns a <see cref="T:System.Windows.DataTemplate"/> based on custom logic.
        /// </summary>
        /// <param name="item">The data object for which to select the template.</param>
        /// <param name="container">The data-bound object.</param>
        /// <returns>
        /// Returns a <see cref="T:System.Windows.DataTemplate"/> or null. The default value is null.
        /// </returns>
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var user = item as User;
            return user == null ? base.SelectTemplate(item, container) : this.UserTemplate;
        }
    }
}